import axios from "axios";

class URL {
  constructor(url, suffixed) {
    this.url = url;
    this.suffixed = suffixed;
  }
  build() {
    return this.url;
  }
}

const URLS = {
  SYSTEM: new URL("http://localhost:8186/config/detail/search"),
  TENANT: new URL("http://localhost:8186/config/detail/tenant/search"),
  ROLE: new URL("http://localhost:8186/config/detail/tenant/role/search")
};

export default {
  async search({ scope, filter = { page: 1, size: 10 } }) {
    let url = URLS[scope];
    let response = url ? await axios.post(url.build(), filter) : null;
    return response;
  }
};
